package com.zjh.rabbitmq.config;


import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.amqp.core.*;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class RabbitConfig {

    @Bean
    public FanoutExchange exchange(){
        return new FanoutExchange("fanout_exchange");
    }

    @Bean
    public Queue queue1(){
        return new Queue("simple.queue");
    }

    @Bean
    public Binding builder(Queue queue1,FanoutExchange exchange){
        return BindingBuilder.bind(queue1).to(exchange);
    }

    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }
}
